package com.iflyun.demo.interceptor;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import com.iflyun.rabbitmq.controller.UserLogs;





public class UserActionLogSaveInterceptor implements HandlerInterceptor {
	

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object arg2)throws Exception  {
		//final HttpServletRequest request1 =request;
		//final HttpServletResponse response1=response;
		long t=System.currentTimeMillis();
		UserLogs userLog = new UserLogs();	
		float f=0; 
		String userid = "abc";//获取userid，如果没有则为空
		List<String> list = new ArrayList<String>();
		list.add("/resources");
		list.add("/admin");
		request.setAttribute("", "");
		try {
		for (int i = 0; i < 100000; i++) {
			userLog.WebLogSave(request, response, list, userid, null, null, "0.0.x", "0601");
//			userLog.WeChatLogSave(request,response, list, userid,"openid", null, "operationType", f,
//					f, "mobilePhoneBrand", "operatingSystem","0.0.x", "0601");
			
		}
				

			
		} catch (Exception e) {
			// TODO: handle exception
			System.out.println(e.getMessage());
		}
		
		System.out.println("插入成功");
		return true;
	}

	@Override
	public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
			throws Exception {
	}

	@Override
	public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
			throws Exception {
	}

}
